package com.chookss.home.other;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chookss.R;
import com.chookss.Urls;
import com.chookss.base.StaticClass;
import com.chookss.base.X5WebView;
import com.chookss.login.LoginActivity;
import com.chookss.tiku.FeedbackActivity;
import com.chookss.tools.MyEvent;
import com.chookss.tools.MyToast;
import com.chookss.tools.NavigationTools;
import com.chookss.tools.Utils;
import com.chookss.tools.XJson;
import com.chookss.tools.okgoconfig.MyHttpRequest;
import com.chookss.tools.okgoconfig.callback.JsonCallback;
import com.johnrambo.ktea.ktExtends.ShareUtils;
import com.lvgroup.hospital.base.BaseAct;
import com.lzy.okgo.model.Response;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.Nullable;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class NoMoneyActivity extends BaseAct {
    @BindView(R.id.common_title_txt)
    TextView commonTitleTxt;
    @BindView(R.id.webView)
    X5WebView webView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_no_money);
        ButterKnife.bind(this);
        initState();
    }

    @Override
    public void initData() {
        commonTitleTxt.setText("登录");
        showLoading();
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView webView, String s) {
                super.onPageFinished(webView, s);
                try {
                    dismissLoading();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        String url=Urls.indexPrivacy+"?companyName="+new ShareUtils().getString(this, StaticClass.COMPANYNAME,"");
        webView.loadUrl(url);
    }

    private void goBack() {
        //按下返回键或者左上角返回箭头的操作
        if (null == webView.getUrl()) {
            finish();
        }
        if (null == webView) return;
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        finish();

    }

    @Override
    public void onBackPressed() {
        goBack();
    }

    @OnClick({R.id.common_title_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_title_back:
                goBack();
                break;
        }
    }
}
